package introductory;
import java.util.ArrayList;
import java.util.Collection;

import JaCoP.constraints.XmulCeqZ;
import JaCoP.constraints.XmulYeqZ;
import JaCoP.constraints.XplusYeqZ;
import JaCoP.core.IntVar;
import JaCoP.core.Store;


public class Item {
	IntVar totalWeight;
	IntVar quantity;
	IntVar totalCost;
	String name;
	public Item(String name, int cost, int weight, Store store){
		this.name=name;
		this.totalWeight= new IntVar(store,name+"TotalWeight", 0, 500);
		quantity=new IntVar(store,name+"Quantity",0,500); //100 borde vara integer.maxval
		totalCost=new IntVar(store,name+"TotalCost",0,500);//99999 borde vara Integer.maxval
		store.impose(new XmulCeqZ(quantity,cost,totalCost));
		store.impose(new XmulCeqZ(quantity,weight,totalWeight));
	}
	public IntVar getTotalCost(){
		return totalCost;
	}
	public IntVar getTotalWeight(){
		return totalWeight;
	}
	public String toString(){
		return name+": "+quantity+"st "+totalCost+"kr "+totalWeight+"g";
	}
	public IntVar getQuantity(){
		return quantity;
	}
	public Collection<? extends IntVar> getVars() {
		ArrayList<IntVar> vars=new ArrayList<IntVar>();
		vars.add(totalWeight);
		vars.add(quantity);
		vars.add(totalCost);
		return vars;
	}
}
